Assuming you have already created the VR world and node information atom containers, Listing 5-2 shows the code (minus error checking) you would use to add them to the QTVR track.
Listing 2 Adding atom containers to a track
long descSize;
QTVRSampleDescriptionHandle qtvrSampleDesc;
// Create a QTVR sample description handle
descSize = sizeof(QTVRSampleDescription) + GetHandleSize((Handle) vrWorld) -
sizeof(UInt32);
qtvrSampleDesc = (QTVRSampleDescriptionHandle) NewHandleClear (descSize);
(*qtvrSampleDesc)->size = descSize;
(*qtvrSampleDesc)->type = kQTVRQTVRType;
// Copy the vrWorld atom container data into the QTVR sample description
BlockMove (*((Handle) vrWorld), &((*qtvrSampleDesc)->data),
GetHandleSize((Handle) vrWorld));
// Now add it to the QTVR track's media
err = BeginMediaEdits (qtvrMedia);
err = AddMediaSample (qtvrMedia, (Handle) nodeInfo, 0,
GetHandleSize((Handle) nodeInfo), duration,
(SampleDescriptionHandle) qtvrSampleDesc, 1, 0, &sampleTime);
err = EndMediaEdits (qtvrMedia);
InsertMediaIntoTrack (qtvrTrack, trackTime, sampleTime, duration, 1L<<16);
The duration value is computed based on the duration of the corresponding image track samples for the node. The value of trackTime is the time for the beginning of the current node (zero for a single node movie). The values of duration and sampleTime are in the time base of the media; the value of trackTime is in the movie's time base.
| Previous | Chapter Contents | Chapter Top | Next |